package uid

import (
	"log/slog"
	"sync"
	"sync/atomic"
)

var (
	loggerInstance = atomic.Pointer[slog.Logger]{}
	loggerOnce     sync.Once
)

func GetLogger() *slog.Logger {
	loggerOnce.Do(func() {
		if loggerInstance.Load() == nil {
			loggerInstance.Store(slog.Default())
		}
	})
	return loggerInstance.Load()
}
func SetLogger(log *slog.Logger) {
	if log != nil {
		loggerInstance.Store(log)
	}
}
